﻿#include "ArString.hpp"
#include <stdio.h>
#include <string>
#include <atlbase.h>
#include <atlstr.h>

using namespace std;
using namespace Aria;

#define LOOP_COUNT (200 * 10000)

int main(int argc, char* argv[])
{
#ifdef ARIA_DEBUG
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
#endif

	{
		DWORD startTS = GetTickCount();

		for (int i = 0; i < LOOP_COUNT; ++i)
		{
			StringU str1 = L"This is a very long text.";
			StringU str2 = str1; 
			StringU str3 = L"this is a text." + str2 + L"This is another text.";

			//GetModuleFileNameW(NULL, str3.GetBuffer(MAX_PATH), MAX_PATH);
			//str3.ReleaseBuffer();
		}

		DWORD endTS = GetTickCount();
		printf("Aria::StringU cost: %.3f ns\n", (endTS - startTS) * 1000000.0 / LOOP_COUNT);
	}

	{
		DWORD startTS = GetTickCount();

		for (int i = 0; i < LOOP_COUNT; ++i)
		{
			wstring str1 = L"This is a very long text.";
			wstring str2 = str1; 
			wstring str3 = L"this is a text." + str2 + L"This is another text.";

			//str3.reserve(MAX_PATH);
			//GetModuleFileNameW(NULL, &str3[0], MAX_PATH);
			//str3.resize(wcslen(str3.c_str()));
		}

		DWORD endTS = GetTickCount();
		printf("std::wstring cost: %.3f ns\n", (endTS - startTS) * 1000000.0 / LOOP_COUNT);
	}

	{
		DWORD startTS = GetTickCount();

		for (int i = 0; i < LOOP_COUNT; ++i)
		{
			CStringW str1 = L"This is a very long text.";
			CStringW str2 = str1; 
			CStringW str3 = L"this is a text." + str2 + L"This is another text.";

			//str3.reserve(MAX_PATH);
			//GetModuleFileNameW(NULL, &str3[0], MAX_PATH);
			//str3.resize(wcslen(str3.c_str()));
		}

		DWORD endTS = GetTickCount();
		printf("CStringW cost: %.3f ns\n", (endTS - startTS) * 1000000.0 / LOOP_COUNT);
	}
	
	//system("PAUSE");
	return 0;
}

